Skip to content

Conversation

@danielhartnell
Copy link
Contributor

@danielhartnell danielhartnell commented Dec 19, 2024

Relates to: #124

This attempts to determine if there was a cache hit and then records that along with cache key, operation name and path attributes.

By default, this calls cache_lookup_event() which has no action.

Implementing the gem in the parent application would enable monitoring (or whatever) of these cache hits. In our case, we probably just want to increment a cache hit or miss metric tagged with the path and operation name.

module GraphQL
  module FragmentCache
    class Fragment
      def self.cache_lookup_event(**args)
        # Monitoring such as incrementing cache hit counter
      end
    end
  end
end

Copy link
Owner

@DmitryTsepelev DmitryTsepelev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Could you please make Rubocop pass and maybe add something to docs before I merge it in? 🙂

@danielhartnell
Copy link
Contributor Author

Happy New Year @DmitryTsepelev! The Rubocop violation was fixed and I included some documentation in the readme. It felt reasonable to make this a configurable feature so I disabled it by default and added the ability to enable it, like caching itself, via GraphQL::FragmentCache.monitoring_enabled.

Let me know if you'd like me to change anything.

Copy link
Owner

@DmitryTsepelev DmitryTsepelev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you so much and happy new year!

@DmitryTsepelev DmitryTsepelev merged commit 2cffc00 into DmitryTsepelev:master Jan 3, 2025
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants